package com.bjsxt.config.mybatisplus;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
import com.baomidou.mybatisplus.extension.incrementer.H2KeyGenerator;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan("com.bjsxt.mapper")
public class MybatisplusConfig {

/**
 * 分页插件
 */
@Bean
    public PaginationInterceptor paginationInterceptor(){
    PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
    paginationInterceptor.setDbType(DbType.MYSQL);
    return paginationInterceptor;
}


/**
 * 乐观锁
 */
@Bean
public OptimisticLockerInterceptor optimisticLockerInterceptor(){
    OptimisticLockerInterceptor optimisticLockerInterceptor = new OptimisticLockerInterceptor();
    return  optimisticLockerInterceptor;
}

/**
 * 主键序列生成
 * ID_WORK 数字
 * ID_WORK_STR 字符串
 */
public IKeyGenerator iKeyGenerator(){
    H2KeyGenerator h2KeyGenerator = new H2KeyGenerator();
    return h2KeyGenerator ;
}


}
